﻿<template>
  <a-modal
    :title="title"
    width="40%"
    :visible="visible"
    :confirmLoading="loading"
    @ok="handleSubmit"
    @cancel="()=>{this.visible=false}"
  >
    <a-spin :spinning="loading">
      <a-form-model ref="form" :model="entity" :rules="rules" v-bind="layout">
        <a-form-model-item label="代发批次ID" prop="TBID">
          <a-input v-model="entity.TBID" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="服务商ID" prop="SID">
          <a-input v-model="entity.SID" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="服务商名称" prop="ServiceName">
          <a-input v-model="entity.ServiceName" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="结算规则" prop="ruleType">
          <a-input v-model="entity.ruleType" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="签约费率" prop="SignRate">
          <a-input v-model="entity.SignRate" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="结算费率" prop="SettleRate">
          <a-input v-model="entity.SettleRate" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="佣金" prop="Commission">
          <a-input v-model="entity.Commission" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="客户ID" prop="MID">
          <a-input v-model="entity.MID" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="客户名称" prop="MerchantName">
          <a-input v-model="entity.MerchantName" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="代理商ID" prop="AID">
          <a-input v-model="entity.AID" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="代理商名称" prop="AgentName">
          <a-input v-model="entity.AgentName" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="结算状态" prop="SettleStatus">
          <a-input v-model="entity.SettleStatus" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="支付日期" prop="PayDate">
          <a-input v-model="entity.PayDate" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="总金额" prop="TotalAmount">
          <a-input v-model="entity.TotalAmount" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="笔数" prop="TotalNum">
          <a-input v-model="entity.TotalNum" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="充值金额" prop="RechargeAmount">
          <a-input v-model="entity.RechargeAmount" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="交易日期" prop="tradeDate">
          <a-input v-model="entity.tradeDate" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="代理商级别" prop="AIDLevel">
          <a-input v-model="entity.AIDLevel" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="商务经理ID" prop="customerManagerId">
          <a-input v-model="entity.customerManagerId" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="商务经理" prop="customerManager">
          <a-input v-model="entity.customerManager" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="一级代理ID" prop="OneLevelAID">
          <a-input v-model="entity.OneLevelAID" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="一级代理签约费率" prop="OneLevelSignRate">
          <a-input v-model="entity.OneLevelSignRate" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="一级代理佣金" prop="OneLevelCommission">
          <a-input v-model="entity.OneLevelCommission" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="二级代理ID" prop="TwoLevelAID">
          <a-input v-model="entity.TwoLevelAID" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="二级代理签约费率" prop="TwoLevelSignRate">
          <a-input v-model="entity.TwoLevelSignRate" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="二级代理佣金" prop="TwoLevelCommission">
          <a-input v-model="entity.TwoLevelCommission" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="三级代理ID" prop="ThreeLevelAID">
          <a-input v-model="entity.ThreeLevelAID" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="三级代理签约费率" prop="ThreeLevelSignRate">
          <a-input v-model="entity.ThreeLevelSignRate" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="三级代理佣金" prop="ThreeLevelCommission">
          <a-input v-model="entity.ThreeLevelCommission" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="交易年度" prop="tradeYear">
          <a-input v-model="entity.tradeYear" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="交易月份" prop="tradeMonth">
          <a-input v-model="entity.tradeMonth" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="可结算年月" prop="CanSettleDate">
          <a-input v-model="entity.CanSettleDate" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="结算周期" prop="SettlementInterval">
          <a-input v-model="entity.SettlementInterval" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="结算文件地址" prop="SettlementFilePath">
          <a-input v-model="entity.SettlementFilePath" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="数据范围ID" prop="DataAreaId">
          <a-input v-model="entity.DataAreaId" autocomplete="off" />
        </a-form-model-item>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>

<script>
export default {
  props: {
    parentObj: Object
  },
  data() {
    return {
      layout: {
        labelCol: { span: 5 },
        wrapperCol: { span: 18 }
      },
      visible: false,
      loading: false,
      entity: {},
      rules: {},
      title: ''
    }
  },
  methods: {
    init() {
      this.visible = true
      this.entity = {}
      this.$nextTick(() => {
        this.$refs['form'].clearValidate()
      })
    },
    openForm(id, title) {
      this.init()

      if (id) {
        this.loading = true
        this.$http.post('/Base_leasesystem_settlement/leasesystem_settlement/GetTheData', { id: id }).then(resJson => {
          this.loading = false

          this.entity = resJson.Data
        })
      }
    },
    handleSubmit() {
      this.$refs['form'].validate(valid => {
        if (!valid) {
          return
        }
        this.loading = true
        this.$http.post('/Base_leasesystem_settlement/leasesystem_settlement/SaveData', this.entity).then(resJson => {
          this.loading = false

          if (resJson.Success) {
            this.$message.success('操作成功!')
            this.visible = false

            this.parentObj.getDataList()
          } else {
            this.$message.error(resJson.Msg)
          }
        })
      })
    }
  }
}
</script>
